import {Component, Input} from "@angular/core";
import {NavController} from "ionic-angular";
import {ActivitDetailPage} from "../../../../pages/activity/acitivity-detail/activit-detail/activit-detail";
import {ActivityStatus} from "../../../../model/pages/activity/activity-filter/activity-filter.model";

@Component({
    selector: 'activity-card',
    templateUrl: 'roster-detail-activity.component.html'
})
export class RosterDetailActivityComponent {
    private _isOpen: Boolean;
    private _activities: Array<any>;
    @Input()
    set activities(activities) {
        activities.forEach((item) => {
            item.isOpen = false;
        });
        this._activities = activities;
    }

    @Input() title: string;
    @Input() classify: any;

    @Input()
    set isOpen(isOpen) {
        this._isOpen = Boolean(isOpen);
    }

    constructor(private navCtrl: NavController) {
    }

    toActivityDetail(item) {
        if (item.status && item.status === ActivityStatus.dropOff) {
            return;
        }
        this.navCtrl.push('ActivitDetailPage', {
            classify: this.classify,
            id: item.id
        });
    }

    hasNextPro(activity) {
        if (this.classify == 0) {
            if (!activity.moreInfo || activity.moreInfo.length === 0) {
                return true;
            }
            return false;
        }
        return false;
    }
}
